package com.bdv.md.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table (name = "LIM_TBL")
@DynamicInsert
@DynamicUpdate
public class LimTbl extends BaseObject {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6L;
	
	private String txId;
	private String limitKredit;
	private String setAlarm;
	private MapTbl mapTbl;

	public LimTbl(){
	}
	
	
	public LimTbl(String txId, String limitKredit, String setAlarm, Integer mapTblId) {
		this.txId = txId;
		this.limitKredit = limitKredit;
		this.setAlarm = setAlarm;
		this.mapTbl = new MapTbl(mapTblId);
	}

	@Id
	@Column(name = "TX_ID")
	public String getTxId() {
		return txId;
	}
	public void setTxId(String txId) {
		this.txId = txId;
	}
	
	@Column(name = "LIMIT_KREDIT")
	public String getLimitKredit() {
		return limitKredit;
	}
	public void setLimitKredit(String limitKredit) {
		this.limitKredit = limitKredit;
	}
	
	@Column(name = "SET_ALARM")
	public String getSetAlarm() {
		return setAlarm;
	}
	public void setSetAlarm(String setAlarm) {
		this.setAlarm = setAlarm;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MAP_ID", nullable = false)
	public MapTbl getMapTbl() {
		return mapTbl;
	}
	public void setMapTbl(MapTbl mapTbl) {
		this.mapTbl = mapTbl;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((limitKredit == null) ? 0 : limitKredit.hashCode());
		result = prime * result + ((mapTbl == null) ? 0 : mapTbl.hashCode());
		result = prime * result
				+ ((setAlarm == null) ? 0 : setAlarm.hashCode());
		result = prime * result + ((txId == null) ? 0 : txId.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		LimTbl other = (LimTbl) obj;
		if (limitKredit == null) {
			if (other.limitKredit != null)
				return false;
		} else if (!limitKredit.equals(other.limitKredit))
			return false;
		if (mapTbl == null) {
			if (other.mapTbl != null)
				return false;
		} else if (!mapTbl.equals(other.mapTbl))
			return false;
		if (setAlarm == null) {
			if (other.setAlarm != null)
				return false;
		} else if (!setAlarm.equals(other.setAlarm))
			return false;
		if (txId == null) {
			if (other.txId != null)
				return false;
		} else if (!txId.equals(other.txId))
			return false;
		return true;
	}


	@Override
	public String toString() {
		return "LimTbl ["
				+ (txId != null ? "txId=" + txId + ", " : "")
				+ (limitKredit != null ? "limitKredit=" + limitKredit + ", "
						: "")
				+ (setAlarm != null ? "setAlarm=" + setAlarm + ", " : "")
				+ (mapTbl != null ? "mapTbl=" + mapTbl : "") + "]";
	}
	
	
	
}
